<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>/mobile/scan/scanMap.jsp</title>

	<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> 

	<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
	<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
	<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
	
	<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true" ></script>
	<script type="text/javascript">
		window.addEventListener('load', function() {
			setTimeout(scrollTo, 0, 1);
			},
			false);
	
		$(document).on("pageshow", "#scanMap", function(){
			navigator.geolocation.getCurrentPosition(
				successCallback,
				errorCallback
			);			
			function successCallback(position){
				var lat = position.coords.latitude;
				var lng = position.coords.longitude;
				
				var map_div = document.getElementById("map_div");
				map_div.style.width = $(window).width()+"px";
				map_div.style.height = $(window).height()-$("#topNavbarId").height()+"px";
				var latlng = new google.maps.LatLng(lat, lng);
				var gmap = new google.maps.Map(
					map_div, 
					{zoom: 15, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP}		
				);
				var marker = new google.maps.Marker({
					position: latlng,
					map: gmap
				});
				
				
				
			}
			function errorCallback(err){
				alert("위치정보를 가져오는데 실패했습니다");
				
				var map_div = document.getElementById("map_div");
				map_div.style.width = $(window).width()+"px";
				map_div.style.height = $(window).height()+"px";
				var latlng = new google.maps.LatLng(37.521636, 126.92411);
				var gmap = new google.maps.Map(
					map_div, 
					{zoom: 15, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP}		
				);
			}
			
			
		});

	</script>

</head>
<body>
<div id="scanMap" data-role="page" data-theme="c">

	<div data-role="header" data-position="fixed" data-theme="b">
		<a href="${cPath }/logout.mo" data-icon="back" data-ajax="false">로그아웃</a>
		<h1 >벗</h1>
		<div id="topNavbarId" data-role="navbar" data-iconpos="top" >
			<ul>
				<li><a href="#" data-icon="grid" >Scan</a></li>
				<li><a href="${cPath }/bud/budList.mo" data-icon="star">Bud</a></li>
				<li><a href="#" data-icon="gear">Chat</a></li>
				<li><a href="#" data-icon="gear">Settings</a></li>
			</ul>
		</div>
		
	</div>

	<div data-role="content" style="padding:0px;">
		<div id="map_div" style="width:100%; height:100%"></div>
	</div>

	
	<div data-role="footer" data-position="fixed" data-theme="b">		
		<div data-role="navbar">
			<ul>
				<li><a href="#" >Map</a></li>
				<li><a href="${cPath }/scan/scanList.mo" >List</a></li>
			</ul>
		</div>
	</div>
	
</div><!-- /page -->
</body>
</html>